<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div> 我是第一个页面</div>
    <div>
        <input id="msg"/>
        <button id="btn">把第一个页面的数据给第二个页面</button>
    </div>
    <iframe  id="iframe" src="http://127.0.0.1:5500/lesson18/02.html" height="600" width="100%"></iframe>
</body>
<script>
    let  btn  = document.getElementById("btn");

    btn.onclick = function(){
        document.getElementById("iframe").contentWindow.postMessage(msg.value, '*'); 
    }


</script>

</html>